angular.module('myApp', ['infinite-scroll']);
function orderPj($scope, $http) {
	url = getUrl("66selectNoPJ");
	header = getHeader();
	$scope.pages = 0;
	//默认加载第一页，初始值0
	$scope.orderList = [];
	$scope.totalpage = 1;
	//总页数初始默认1，读取数据后再更新
	$scope.loadMore = function() {
			if ($scope.pages < $scope.totalpage) {
				params = 'account=' + readData(localStorage.phone) + '&indexpage=' + $scope.pages + '&pageSize=10&closedComment=n'
				$scope.pages = $scope.pages + 1;
				$http({
					method: 'POST',
					url: url,
					headers: header,
					timeout: 10000,
					//cache: true,
					data: params
				}).success(function(data, status, headers, config) {

					if (data.orderList) {
						//var orderList = data.orderList;
						//规格尺寸显示隐藏判断
						var produ = data.orderList;
						for (var i = 0; i < produ.length; i++) {
							for (var j = 0; j < produ[i].list.length; j++) {
								if (produ[i].list[j].speccolor) {
									produ[i].list[j].ngcolor = "false";
								} else {
									produ[i].list[j].ngcolor = "true";
								}
								if (produ[i].list[j].specsize) {
									produ[i].list[j].ngsize = "false";
								} else {
									produ[i].list[j].ngsize = "true";
								}
								if (produ[i].list[j].specspec) {
									produ[i].list[j].ngspec = "false";
								} else {
									produ[i].list[j].ngspec = "true";
								}
								if (produ[i].list[j].specmodel) {
									produ[i].list[j].ngmodel = "false";
								} else {
									produ[i].list[j].ngmodel = "true";
								}
								produ[i].heji = (parseFloat(produ[i].amount) - parseFloat(produ[i].discountPay)).toFixed(2);
							}
						}
						var orderList = produ;
						for (var i = 0; i < orderList.length; i++) {
							if (orderList[i]['isRefund'] != "n") {
								continue;
							}
							$scope.orderList.push(orderList[i])
						}
						$scope.totalpage = data.totalpage;
						//下拉页面+1
					} else {
						$scope.pages = $scope.pages - 1;
						$scope.orderList = [];
					}
				}).error(function(data, status, headers, config) {
					mui.toast('网络链接异常，请稍后重试(e)');
					$scope.pages = $scope.pages - 1;
				});
			}
		}
		//联系导购
	$scope.openGuidechart = function(order) {
			delete localStorage.daogou;
			localStorage.daogou = writeData(JSON.stringify(order));
			orders = eval('(' + readData(localStorage.daogou) + ')');
			localStorage.chatName = writeData('guidChat');
			mui.openWindow({
				url: '../chat/friendChat.html',
				id: 'friendChat.html'
			});
		}
		//打开订单评价
	$scope.orderPj = function(order) {
			localStorage.order = writeData(JSON.stringify(order));
			openOrderJudge();
		}
		//打开订单明细
	$scope.orderDetail = function(order) {
		localStorage.order = writeData(JSON.stringify(order));
		openOrderDetail();
	}
}